import { observable,action } from 'mobx-miniprogram'


export const store = observable({
  // 数据字段
  numA: 1,
  numB: 2,
  active: 0,
  // 计算属性
  get sum() {
    return this.numA + this.numB
  },
  setActive: action(function(current) {
    this.active = current
  }),
  // 修改数据字段
  addNumAWithStep: action(function(step) {
    this.numA += step
  }),
  subNumAWithStep: action(function(step) {
    this.numA -= step
  }),
  addNumBWithStep: action(function(step) {
    this.numB += step
  }),
  subNumBWithStep: action(function(step) {
    this.numB -= step
  }),
})